package glemipsc;

import java.io.Serializable;
import java.util.List;

import glemipsc.implementations.Argument;
import glemipsc.implementations.Implementation;
import glemipsc.implementations.Instruction;
import glemipsc.instructions.Expression;

public class ConstantChar implements Expression, Serializable {
	private String str;
	private Type type;

	public ConstantChar(String str) {
		this.str = str;
		type = new TypeChar();
	}

	public Type getType() {
		return type;
	}

	public boolean isImmediate() {
		return true;
	}

	public int getImmediateValue() {
		return str.charAt(0);
	}

	public Address getStoreAddress() {
		return null;
	}

	public boolean isStored() {
		return false;
	}

	public void setStoreAddress(Address addr) {
		
	}

	public int getStoredSize() {
		return 0;
	}

	public void computeInstruction(Argument result, List<Instruction> instructions, Function func) {
		Implementation impl = GLEMipsC.compiler.getEnvironment().implementation;
		instructions.add(impl.getMov(result, impl.getImmediate(this.getImmediateValue())));
	}
}
